//
//  CustomLabel.m
//  Label自动换行
//
//  Created by noteverlong on 14-8-12.
//  Copyright (c) 2014年 NJRY. All rights reserved.
//

#import "CustomLabel.h"

@implementation CustomLabel

- (id)initWithFrame:(CGRect)frame andTextString:(NSString *)str andFontSize:(CGFloat)fontSize
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        [self setNumberOfLines:0];
        UIFont * ffont =[UIFont fontWithName:nil size:fontSize];
        //设置一个行高上线
        CGSize size =CGSizeMake(frame.size.width, 200000);
        CGSize labelSize= [str sizeWithFont:ffont constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
        [self setFrame:CGRectMake(frame.origin.x, frame.origin.y, labelSize.width, labelSize.height)];
        self.text =str;
        [self setFont:[UIFont fontWithName:nil size:13]];
//        self.layer.cornerRadius =5;
//        self.layer.borderWidth=0.5;
//        self.backgroundColor =[UIColor redColor];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
